<template>
    <rx-layout>
        <div slot="center" style>
            <rx-fit>
                <div slot="toolheader" foldheader="true" foldbtn="false" border="false">
                    <div class="table-page-search-wrapper" v-if="showSearch==true">
                        <a-form layout="inline">
                            <a-row :gutter="24">
                                <a-col :span="8">
                                    <a-form-item label="SETTING_NAME_">
                                        <a-input :placeholder="$ti18('','','input') + SETTING_NAME_"
                                                 v-model="queryParam.Q_SETTING_NAME__S_LK"/>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="8">
                                    <a-form-item label="TIME_INTERVALS_">
                                        <a-input placeholder="请输入TIME_INTERVALS_"
                                                 v-model="queryParam.Q_TIME_INTERVALS__S_LK"/>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="colSpan" v-if="!curApp.appId">
                                    <a-form-item :label="$ti18('rxForm.appId', '应用')">
                                        <rx-search-app @change="appChange" v-model="searchApps">
                                        </rx-search-app>
                                    </a-form-item>
                                </a-col>
                                <template v-if="advanced">

                                </template>
                                <a-col :md="8" :sm="24">
              <span class="table-page-search-submitButtons">
                <a-button @click="$refs.table.loadData()" icon="search" type="primary">
                    {{$ti18('rxList.searchBtn','查询')}}
                </a-button>
                <a-button @click="resetSearch" style="margin-left: 4px">
                    {{$ti18('rxList.resetBtn','重置')}}
                </a-button>
                <a @click="toggleAdvanced" style="margin-left: 8px">
                  {{ advanced ? '收起' : '展开' }}
                  <a-icon :type="advanced ? 'up' : 'down'"/>
                </a>
              </span>
                                </a-col>
                            </a-row>
                        </a-form>
                    </div>
                    <div class="table-operator">
                        <a-button type="primary" icon="plus" @click="add">
                            {{$ti18('rxList.newBtn','新建')}}
                        </a-button>
                        <a-dropdown v-if="removeEnable && selectedRowKeys.length > 0">
                            <a-button type="danger" icon="delete" @click="delByIds(selectedRowKeys)">
                                {{$ti18('rxList.delBtn','删除')}}
                            </a-button>
                        </a-dropdown>
                        <span style="float:right">
          <!-- <a-button type="primary" shape="circle" icon="sync" :size="small" @click="refreshGrid"></a-button>
           <a-button type="primary" shape="circle" icon="search" :size="small" @click="toggleSearch"></a-button>-->
         </span>
                    </div>
                </div>
                <rx-grid
                    ref="table"
                    :allowRowSelect="true"
                    :multiSelect="true"
                    :columns="columns"
                    :bordered="isBorder"
                    :defaultPageSize="10"
                    url="/api-bpm/bpm/core/bpmCalTimeBlock/query"
                    :queryParam="queryParam"
                    data-field="result.data"
                    :pageSizeOptions="['10','30','40']"
                    id-field="settingId"
                    @selectChange="onSelectChange"
                >
            <span slot="appId" slot-scope="{ text, record }">
              {{allApps[text]?$i18(allApps[text].appName,'应用名称'):$ti18('rxList.noAppName','无')}}
            </span>
                    <span slot="action" slot-scope="{ text, record }" class="actionIcons">
            <span v-if="editEnable" @click.stop="edit(record)">
                {{$ti18('rxList.editBtn','编辑')}}
            </span>
            <span v-if="removeEnable" @click.stop="delByIds([record.settingId])">
                {{$ti18('rxList.delBtn','删除')}}
            </span>
          </span>
                </rx-grid>
            </rx-fit>
        </div>
    </rx-layout>
</template>

<script>
    import BpmCalTimeBlockApi from '@/api/bpm/core/bpmCalTimeBlock'
    import BpmCalTimeBlockEdit from './BpmCalTimeBlockEdit'
    import {BaseList} from '@lowcode/jpaas-common-lib';
    import {mapState} from 'vuex';
    import SysAppApi from "@/api/system/core/sysApp";
    import AppSearch from "@/views/modules/share/AppSearch";
    import RxSearchApp from "@/views/modules/share/rx-search-app";
    export default {
        name: 'BpmCalTimeBlockList',
        mixins: [BaseList,AppSearch],
        components:{
            RxSearchApp
        },
        computed: {
            ...mapState({
                // 所属应用
                allApps: state => state.appSetting ? state.appSetting.allApps : {}
            }),
        },
        data() {
            return {
                columns: [
                    {
                        title: this.$ti18('rxList.index', '序号'),
                        type: 'indexColumn',
                        width: 40,
                        dataIndex: 'serial',
                        scopedSlots: {customRender: 'serial'}
                    },
                    {title: this.i18n('form.shiftName', '班次名称'), dataIndex: 'settingName', width: 140},
                    {
                        title: this.i18n('form.application', '所属应用'),
                        dataIndex: 'appId',
                        width: 140,
                        sortField: 'APP_ID_',
                        scopedSlots: {customRender: 'appId'}
                    },
                    {
                        title: this.$ti18('rxForm.createTime', '创建时间'),
                        dataIndex: 'createTime',
                        sorter: true,
                        sortField: 'CREATE_TIME_',
                        width: 120
                    },
                    {
                        title: this.$ti18('rxList.action', '操作'),
                        width: 40,
                        dataIndex: 'action',
                        scopedSlots: {customRender: 'action'}
                    }
                ],
                component: BpmCalTimeBlockEdit,
                comment: this.i18n('list.comment', '工作时间段设定'),
                widthHeight: ['800px', '600px'],
            }
        },
        methods: {
            i18n(name, text, key) {
                return this.$ti18(name, text, "bpmCalTimeBlock", key);
            },
            delById(ids) {
                return BpmCalTimeBlockApi.del({ids: ids.join(',')});
            },
            getListByParams(parameter) {
                return BpmCalTimeBlockApi.query(parameter)
            },

        }
    }
</script>
<style scoped>

</style>

